module Input.Mouse;

public class BasicMouse {
	protected int _buttonCnt;
	protected bool[] _button;
	protected int _x , _y;
	protected int _mx , _my;
	protected int _deltaY , _deltaX;
/*
	public class button {
		public bool opIndex( int i ) {
			if ( i < 0 || i >= BUTTONS ) return false;
			return _button[i];
		} //
		public void set( int i , bool v ) {
			if ( i < 0 || i >= BUTTONS ) return;
			_button[i] = v;
		}
	} //
*/	
	public this( int buttonCnt = 10 ) {
		_buttonCnt = buttonCnt;
		_button = new bool[buttonCnt];
		reset();
	} //
	
	public void reset() {
		_x = 0;
		_y = 0;
		_mx = 0;
		_my = 0;
		_deltaX = 0;
		_deltaY = 0;
		for ( int i = 0 ; i < _buttonCnt ; i++ ) _button[ i ] = false;
	} //
	
	public bool isMoved() {
		return ( _mx != 0 || _my != 0 || _deltaX != 0 || _deltaY != 0 );
	} //

	public bool[] button() {
		return _button;
	} //

	public int x(){
		return _x;
	} //

	public int y(){
		return _y;
	} //

	public void x( int v ) {
		_mx = ( v - _x );
		_x = v;
	} //

	public void y( int v ) {
		_my = ( v - _y );
		_y = v;
	} //
	
	public int motionX() {
		int ret = _mx;
		_mx = 0;
		return ret;
	} //

	public int motionY() {
		int ret = _my;
		_my = 0;
		return ret;
	} //
	
	public int deltaX() {
		int ret = _deltaX;
		_deltaX = 0;
		return ret;
	} //

	public int deltaY(){
		int ret = _deltaY;
		_deltaY = 0;
		return ret;
	} //
	public alias deltaY delta;

	public void deltaX( int v ) {
		_deltaX = v;
	} //

	public void deltaY( int v ) {
		_deltaY = v;
	} //
	
	
} //
